home *** CD-ROM | disk | FTP | other *** search
- #! /bin/sh
- ### BEGIN INIT INFO
- # Provides: htpdate
- # Default-Start:
- # Default-Stop:
- # Required-Start: mountkernfs $local_fs
- # Required-Stop:
- # Short-Description: Set time using HTP
- # Description: Set time using HTP
- ### END INIT INFO
-
- DESC="Setting time using HTP"
- NAME=htpdate
- SCRIPTNAME=/etc/init.d/$NAME
- HTP_DIR=/var/run/$NAME
- PIDFILE=$HTP_DIR/pid
- HTP_DONE_FILE=$HTP_DIR/done
- HTP_SUCCESS_FILE=$HTP_DIR/success
- LOG=/var/log/$NAME.log
-
- # Load the VERBOSE setting and other rcS variables
- . /lib/init/vars.sh
-
- # Define LSB log_* functions.
- # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
- # and status_of_proc is working.
- . /lib/lsb/init-functions
-
- # Create status directory and log file
- install -o root -g root -m 0755 -d ${HTP_DIR}
- install -o htp -g nogroup -m 0644 /dev/null ${LOG}
-
- # Source configuration
- . /etc/default/$NAME
-
- log() {
- echo "$@" >> "${LOG}"
- }
-
- # Sanity checks
- if [ -z "$HTTP_USER_AGENT" ]; then
- log "HTTP_USER_AGENT is not set."
- exit 2
- fi
- if [ -z "$HTP_POOL_PAL" ]; then
- log "HTP_POOL_PAL is not set"
- exit 3
- fi
- if [ -z "$HTP_POOL_NEUTRAL" ]; then
- log "HTP_POOL_NEUTRAL is not set"
- exit 3
- fi
- if [ -z "$HTP_POOL_FOE" ]; then
- log "HTP_POOL_FOE is not set"
- exit 3
- fi
-
- do_start() {
- if [ -e "$HTP_DONE_FILE" ]; then
- rm -f "$HTP_DONE_FILE"
- fi
-
- if [ -e "$HTP_SUCCESS_FILE" ]; then
- rm -f "$HTP_SUCCESS_FILE"
- fi
-
- start-stop-daemon -S -q -p ${PIDFILE} -bm -x /usr/local/sbin/htpdate -- \
- --debug \
- --log_file "$LOG" \
- --user_agent "$HTTP_USER_AGENT" \
- --allowed_per_pool_failure_ratio 0.34 \
- --user htp \
- --done_file "$HTP_DONE_FILE" \
- --success_file "$HTP_SUCCESS_FILE" \
- --pal_pool "$HTP_POOL_PAL" \
- --neutral_pool "$HTP_POOL_NEUTRAL" \
- --foe_pool "$HTP_POOL_FOE" \
- --proxy 127.0.0.1:9062
-
- return $?
- }
-
- do_stop() {
- start-stop-daemon -K -q -p ${PIDFILE}
- }
-
- case "$1" in
- start)
- [ "$VERBOSE" != no ] && log_daemon_msg "$DESC" "$NAME"
- do_start
- case "$?" in
- 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
- 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
- esac
- ;;
- stop)
- do_stop
- ;;
- restart)
- do_stop
- do_start
- ;;
- *)
- echo "Usage: $SCRIPTNAME (start|stop|restart)" >&2
- exit 3
- ;;
- esac
-
- :
-